#!/sbin/openrc-run

# These awfully long uppercase variables are here only for backward
# compatibility. Do not use them!
: ${logfile:=${DOCKER_REGISTRY_LOGFILE:-"/var/log/docker-registry.log"}}
: ${conffile:=${DOCKER_REGISTRY_CONFIG:-"/etc/docker-registry/config.yml"}}
: ${user:="docker-registry"}
: ${group:="$user"}

name="Docker Registry"

command="/usr/bin/docker-registry"
command_args="serve $conffile"
command_background="yes"

pidfile="/run/$RC_SVCNAME.pid"
start_stop_daemon_args="
	--user $user:$group
	--stdout $logfile
	--stderr $logfile"

required_files="$conffile"

start_pre() {
	checkpath -d -m 0770 -o "$user:$group" /var/lib/registry
	checkpath -f -m 0644 -o "$user:$group" "$logfile"
}
